package demo1;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:lenovo
 * Date:2024-05-21
 * Time:15:09
 */
/*
(1)该类有3个私有成员变量:类型为int的账户id，类型为double的余额 balance，类型为Date的创建日期 dateCreated.
(2)该类有2个构造方法:无参构造方法Account()用默认值初始化id和balance;
   有参数的构造方法 Account(inti,double d)分别用参数初始化id和balance两个构造方法均使用当前时间对 dateCreated 进行初始化。
(3)定义以下成员方法:withdraw(double amount)从账户提取 amount 额度的钱，如果账户余额不够，则打印错误信息;
   deposit(double amount)向账户存入ammount 额度的钱。
 */
public class Account {
    private int id;
    private double balance;
    private Date dataCreated;

    public Account(){
        this.id=id;
        this.balance=balance;
        this.dataCreated=new Date();
    }
    public Account(int id, double balance) {
        this.id = id;
        this.balance = balance;
        this.dataCreated=new Date();
    }
    public void withdraw(double amount){
        if(balance>=amount){
            balance-=amount;
        }else{
            System.out.println("余额不足!!!");
        }
    }

    public void deposit(double amount){
        balance+=amount;
    }

    public int getId() {
        return id;
    }

    public double getBalance() {
        return balance;
    }
}
